package cn.qiguai.sphapi.mapper;

import cn.qiguai.sphapi.controller.request.CommitPayOrderParam;
import cn.qiguai.sphapi.controller.request.GetPageOrderParam;
import cn.qiguai.sphapi.domain.PayOrder;
import cn.qiguai.sphapi.domain.ShoppingCartOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface PayOrderMapper {
	/**
	 * 保存购买订单基本信息
	 * @param param 参数
	 * @return int
	 */
	int insertPayOrder(CommitPayOrderParam param);

	/**
	 * 保存购买订单包含的商品
	 * @param param 参数
	 * @return int
	 */
	int insertPayOrderGoods(CommitPayOrderParam param);

	/**
	 * 修改订单的状态
	 * @param orderId 订单id
	 * @param status 状态
	 * @return int
	 */
	int updatePayOrderStatus(@Param("orderId") int orderId, @Param("status") int status);

	/**
	 * 获取用户订单信息
	 * @param param 参数
	 * @param startIndex 开始索引
	 * @return page
	 */
	List<PayOrder> selectPayOrderByUserId(@Param("param") GetPageOrderParam param, @Param("startIndex") int startIndex);

	/**
	 * 查询用户订单总记录数
	 * @param userId 用户id
	 * @return int
	 */
	int selectPayOrderTotalCount(int userId);

	/**
	 * 通过购买订单id查询购物车订单信息
	 * @param payOrderId 购买订单id
	 * @return list
	 */
	List<ShoppingCartOrder> selectShoppingCartOrderByPayOrderId(int payOrderId);

	/**
	 * 查询指定订单状态
	 * @param orderId 订单id
	 * @return status
	 */
	int selectPayOrderStatus(int orderId);

	/**
	 * 通过购买订单id查询购物车订单id
	 * @param payOrderId 订单id
	 * @return list
	 */
	List<Integer> selectShoppingCartOrderIdByPayOrderId(int payOrderId);
}
